<!--
 * @Description: 安全生产培训考试考场记录表
 * @Autor: cjj
 * @Date: 2023-10-09 14:36:16
 * @LastEditTime: 
-->
<template>
  <div class="TISchedule">
    <div style="padding-right: 7px;">
      <el-button type="primary" style="float:right" @click="exportWord"
        >导出Word</el-button
      >
    </div>
    <div class="mytable" v-loading="loading" style="width:600px">
      <div class="table_title">安全生产培训考试考场记录表</div>
      <el-row class="gaugeOutfit">
        <el-col :span="12" style="padding-left:10px">
          单位名称：（盖章）
        </el-col>
      </el-row>

      <table>
        <tr>
          <td width="20%">
            培训班名称
          </td>
          <td colspan="5">
            <input type="text" v-model="dataForm.className" readonly="readonly" />
          </td>
          <!-- <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td> -->
        </tr>
        <tr>
          <td>
            考试方式
          </td>
          <td colspan="2">
            线上(&nbsp;&nbsp;)/线下(&nbsp;&nbsp;)
          </td>
          <!-- <td>
          </td> -->
          <td colspan="2">
           考试地点
          </td>
          <!-- <td>
          </td> -->
          <td>
            
          </td>
        </tr>
        <tr>
          <td>
            考试时间
          </td>
          <td colspan="5">
            <input type="text" v-model="dataForm.examStartTime" readonly="readonly" />
            -
            <input type="text" v-model="dataForm.examEndTime" readonly="readonly" />
          </td>
          <!-- <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td> -->
        </tr>
        <tr>
          <td>
            应考人数
          </td>
          <td width="15%">
            <input type="text" v-model="dataForm.examNum" readonly="readonly" style="width:100%" />
          </td>
          <td>
            实考人数
          </td>
          <td width="15%">
            <input type="text" v-model="dataForm.actualExamNum" readonly="readonly" style="width:100%"/>
          </td>
          <td>
            缺考人数
          </td>
          <td width="15%">
            <input type="text" v-model="dataForm.hasNotExamNum" readonly="readonly" style="width:100%"/>
          </td>
        </tr>
        <tr>
          <td rowspan="5">
            考场情况记录
          </td>
          <td rowspan="5" colspan="5">
          </td>
          <!-- <td rowspan="5">
          </td>
          <td rowspan="5">
          </td>
          <td rowspan="5">
          </td>
          <td rowspan="5">
          </td> -->
        </tr>
        <tr>
          <!-- <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td> -->
        </tr>
        <tr>
          <!-- <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td> -->
        </tr>
        <tr>
          <!-- <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td> -->
        </tr>
        <tr>
          <!-- <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td> -->
        </tr>
        <tr>
          <td>
            监考人员签名
          </td>
          <td colspan="5">
          </td>
          <!-- <td>
          </td>
          <td>
          </td>
          <td>
          </td>
          <td>
          </td> -->
        </tr>
        <tr>
          <!-- <td colspan="2" style="text-align: center;" valign="middle">博客地址：https://blog.csdn.net/pan_junbiao</td> -->
        </tr>
      </table>
    </div>
  </div>
</template>
<script>
import request from "@/utils/request";
export default {
  name: "TISchedule",
  data() {
    return {
      loading: true,
      dataForm: {},
      list: []
    };
  },
  created() {},
  computed: {
    total() {
      let total = 0;
      this.list.forEach(item => {
        total += Number(item.coursewareTime);
      });
      this.dataForm.total = total;
      return total;
    }
  },
  methods: {
    init(id) {
      this.loading = true;

      request({
        url: "/api/class_archives/generateA16/" + id+`?organizeId=${this.$store.getters.organizeId}`,
        method: "get"
      }).then(res => {
        this.dataForm = res.data;
        // // 创建10位数组
        // this.list = Array.apply(null, { length: 10 }).map(() => {
        //   return { coursewareName: "", coursewareTime: "", teacherName: "" };
        // });
        // // 获取数据数组长度
        // let lgh = this.dataForm.childrenVOList.length;
        // // 替换数组
        // this.list.splice(0, lgh, ...this.dataForm.childrenVOList);
        this.loading = false;
      });
    },
    exportWord() {
      this.dataForm.childrenVOList = this.list;
      for (let key in this.dataForm) {
        if (Array.isArray(this.dataForm[key])) {
          this.dataForm[key].forEach(item => {
            for (let key2 in item) {
              if (item[key2] == null) {
                item[key2] = "";
              }
            }
          });
        } else if (this.dataForm[key] == null) {
          this.dataForm[key] = "";
        }
      }
      this.dataForm.organizeId=this.$store.getters.organizeId;
      request({
        responseType: "blob",
        url: "/api/class_archives/generateA16Export",
        method: "post",
        data: this.dataForm
      }).then(res => {
        var debug = res;
        if (debug) {
          var a = document.createElement("a");
          a.download = "安全生产培训考试考场记录表.docx";
          a.style.display = "none";
          var blob = new Blob([debug], { type: "application/x-msdownload" });
          a.href = URL.createObjectURL(blob);
          document.body.appendChild(a);
          a.click();
          document.body.removeChild(a);
        }
      });
    }
  }
};
</script>
<style scoped lang="scss">
// 引入公共样式
@import "./TABLESTYLE.scss";
</style>
